package cn.vivi.commons.util;

public class Result {

    private static final int  SUCCESS = 1;

    private static final int ERROR = 0;

    private Integer code;
    private String message;
    private Object result;

    private Result() {}

    private Result(Integer code, String message, Object obj) {
        this.code = code;
        this.message = message;
        this.result = obj;
    }

    public static Result success() {
        return new Result(SUCCESS, "成功", null);
    }

    public static Result error() {
        return new Result(ERROR, "失败", null);
    }

    public static Result success(Object obj) {
        return new Result(SUCCESS, "成功", obj);
    }

    public static Result error(String message) {
        return new Result(ERROR, message, null);
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return result;
    }

    public void setData(Object data) {
        this.result = data;
    }
}
